<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="text/javascript" src="../shamcey/js/jquery-1.9.1.min.js"></script>
<link>
<title></title>
<jsp:include page="/common/header.jsp"></jsp:include>
<script type="text/javascript">
   
    $(function(){
     var curpage= $("#nowPage").val();
     var lastpage=$("#totalPage").val();
     //$("").val(curpage);
   /*  alert("curpage="+curpage);
     alert("lastpage="+lastpage);
     */
     if(curpage==1){
         $("#prevbt").attr("disabled", true); 
     }
     if(curpage>=lastpage){
        $("#nextbt").attr("disabled", true); 
     }
     
    
    });
    
    //分页查询调用
    function pageSelect(ob){
       var nowPage=parseInt($("#nowPage").val());
       var lastPage=parseInt($("#totalPage").val());
       var currentPage=nowPage;
       var id=$(ob).attr("id");
       if(id=="firstbt"){
         $("#nowPage").val("1");
         $("#listForm").submit();
       }
       else if(id=="prevbt"){
          currentPage=currentPage-1;
          if(currentPage==1){
             $("#prevbt").attr("disabled", true);
          }
          $("#nowPage").val(currentPage);
          $("#currentpage").html(currentPage);
           $("#listForm").submit();
       
       }else if(id=="nextbt"){
          currentPage=currentPage+1;
        /**  alert("nextbt_curpage="+currentPage);
          alert("nextbt_lastPage="+lastPage);
          */
          if(currentPage>=lastPage){
            $("#nextbt").attr("disabled", true);
          }
          $("#nowPage").val(currentPage);
          $("#currentpage").html(currentPage);
           $("#listForm").submit();
       
       }else{
          currentPage=lastPage;
          $("#nowPage").val(currentPage);
          $("#currentpage").html(currentPage);
           $("#listForm").submit();
       }
      
    }
    //下拉框查询调用
    function searchSelectOper(){
      $("#listForm").submit();
    }
    //搜索框搜索调用
    function titleSearch(){
       $("#listForm").submit();
    }
        
       
    
   
   
   
    
    
</script>
</head>
<body style="background: #fff;width: 98%">


	<div class="pageheader">

		<div class="pageicon">
			<span class="iconfa-table"></span>
		</div>
		<h4 class="widgettitle">Data Table</h4>
		<form id="listForm" action="../vote/list.do" method="post">

			<div style="width:100%;  margin-left: auto;margin-right: auto;"
				align="center">
				<!-- 下拉选项 -->
				<c:choose>
					<c:when test="${!empty LOGINED_USER.uid}">
						<div style="width:10%; float:left; ">
							<label style="left: 20px;"> <select id="select_search"
								onchange="searchSelectOper()" name="select_search">
									<option label="" value="2" <c:if test="${'' eq dataMap.select_search}">selected</c:if> >----全部----</option>
									<option label="" value="0" <c:if test="${'0' eq dataMap.select_search}">selected</c:if> >我发起的投票</option>
									<option label="" value="1" <c:if test="${'1' eq dataMap.select_search}">selected</c:if>>我参与的投票</option>
							</select> </label>
						</div>

					</c:when>
					<c:otherwise>
						<div style="width:10%; float:left; ">
							<label style="left: 20px;"> <select id="select_search"
								onchange="searchSelectOper()" name="select_search">
									<option label="" value="2" <c:if test="${'' eq dataMap.select_search}">selected</c:if> >----全部----</option>
									<option label="" value="0" <c:if test="${'0' eq dataMap.select_search}">selected</c:if> >我发起的投票</option>
									<option label="" value="1" <c:if test="${'1' eq dataMap.select_search}">selected</c:if>>我参与的投票</option>
							</select> </label>
						</div>
					</c:otherwise>
				</c:choose>


				<div style="width:30%; float:right; ">

					<label style="right: 30px;"> 搜索：<input id="title_search"
						name="title_search" value="${dataMap.title_search}"  /> <input type="button" id="title_search" onclick="titleSearch();" value="搜   索"> </label>
				</div>
			</div>

			<br>
			<!-- 
                <div align="left">
              
                <label style="left: 20px;">
                   <select id="select_search" onchange="" name="select_search">
                      <option label="" value="">全部</option>
                      <option label="" value="0">我发起的投票</option>
                       <option label="" value="1">我参与的投票</option>
                   </select>
                </label>
                 
                    <label style="right: 20px;">
                                                           搜索：<input id="title_search" name="title_search" />
                    </label> 
                </div>
                
                <div align="right">
                                                                   
                </div>
                   -->

			<br>
			<div>
				<table id="dyntable" border="1" cellpadding="1" align="center"
					width="100%" frame="box" rules="all">

					<tr style="background-color: gray;">
						<td class="head0 nosort" colspan="1">
						<td class="head1">序号
						</th>
						<td class="head0">标题
						</th>
						<td class="head1">投票类型
						</th>
						<td class="head0">投票发起人
						</th>
						<td class="head1">投票截止时间
						</th>
						<td class="head0">投票发布时间
						</th>
					</tr>

					<tbody>
						<c:forEach items="${dataMap.dataList}" var="obj"
							varStatus="status">
							<tr class="gradeX">
								<td class="aligncenter"><span class="center"> <input id="checkItem"
										type="checkbox" value="${obj.tid}" name="checkItem"/> </span>
								</td>
								<td>${status.index+1}</td>
								<td><a href="">${obj.title}</a></td>
								<td>${obj.type}</td>
								<td>${obj.name}</td>
								<td>${obj.deadline}</td>
								<td>${obj.create_time}</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<div hidden="ture">
			    <input id="uid" name="user_id" value="${sessionScope.LOGINED_USER.uid}">
				<input id="nowPage" name="nowPage" value="${dataMap.nowPage}" /> <input
					id="totalRecord" name="totalRecord" value="${dataMap.totalRecord}">
				<input id="totalPage" name="totalPage" value="${dataMap.totalPage}" />
			</div>

			<c:if test="${dataMap.totalPage>1}">
				<div
					style="margin-left: auto;margin-right: auto; width: 100%;background-color: black;"
					align="center">

					<div style="width:30%; float:left; background-color: gray; ">
						共有<span>${dataMap.totalRecord}</span>条数据，共计<span>${dataMap.totalPage}</span>页
					</div>

					<div style="width:70%; float:right; background-color: gray;">
						<input type="button" id="firstbt"
							style="background-color: gray; border: 0;"
							onclick="pageSelect(this);" value="首 页"> <input
							type="button" id="prevbt"
							style="background-color: gray; border: 0;"
							onclick="pageSelect(this);" value="上一页"> <span
							id="currentpage">${dataMap.nowPage}</span> <input type="button"
							id="nextbt" style="background-color: gray; border: 0;"
							onclick="pageSelect(this);" value="下一页"> <input
							type="button" id="overbt"
							style="background-color: gray; border: 0;"
							onclick="pageSelect(this);" value="尾页" />
					</div>
				</div>
			</c:if>



			<!--  <div style="background-color: gray;">
                    <div  id="dyntable_paginate"><a href="" id="dyntable_first">首页</a><a  href="" id="dyntable_previous">上一页</a><span><a >1</a></span><a href="" id="dyntable_next">下一页</a><a href="" id="dyntable_last">尾页</a></div>
                </div> -->
		</form>

	</div>
	<!--footer-->

	</div>
	<!--maincontentinner-->

	<!--  </div>  maincontent-->
</body>
</html>
